<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>人员</title>
<link rel="stylesheet" type="text/css" href="control.css"/>
<link rel="stylesheet" type="text/css" href="control_main.css" />
<script type="text/javascript">
window.onload = function(){
	searchInfo();
}
function searchInfo(){
	clearUlInner();
	var userName = document.getElementById("un").value;
	var userPlace = document.getElementById("up").value;
	var registerTime = document.getElementById("control_date").value;
	var url = "/networkforum/control/user_control.do";
	
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get(url+"?index=0&size=1000&userName="+encodeURIComponent(userName)+
		"&userPlace="+encodeURIComponent(userPlace)+"&registerTime="+registerTime,function(d){
		var data = toJson(d,"/networkforum/forumcontrol/control_login.html");
		
		//page.view('articleInner',article,articleOption);
		page.view("rightUlInner",data.slice(0,10),userOption);
		window.parent.iFrameHeight();

		paging.page({
			size:10,
			total:Math.ceil(data.length/10),
			data:data,
			ajaxLoad:false,
			previou:document.getElementById("previouPage"),
			next:document.getElementById("nextPage"),
			current:document.getElementById("currentPage"),
			max:document.getElementById("totalPage"),
			callBack:function(d){
				var replyInner = document.getElementById("rightUlInner");
				var first = replyInner.children[0];
				var module = replyInner.children[1];
				replyInner.innerHTML = "";
				replyInner.appendChild(first);
				replyInner.appendChild(module);
				//page.view("replyInner",d,replyOption);
				page.view("rightUlInner",d,userOption);
				moule = null;
				frist= null;
				friendInner = null;
			},
		});
	});
	myajax = null;
}
var userOption = {
	userName:{
		param:{id:"userName"},
		bind:{userId:"userId"},
		style:{color:"blue"}
	},
	userSex:{
		param:{id:"userSex"}
	},
	userAge:{
		param:{id:"userAge"},
	},
	userPlace:{
		param:{id:"userPlace"},
	},
	registerTime:{
		param:{id:"registerTime"},
	},
	lastLoginTime:{
		param:{id:"lastLoginTime"},
	},
	userState:{
		param:{id:"userState"},
	},
	userRole:{
		param:{id:"userRole"}
	},
}
function userHandle(event){
	event = event || window.event;
	var target = event.target || event.srcElement;
	var hs = document.getElementById("handleSelect");
	if(!hs){
		hs = document.getElementById("handle").cloneNode(true);
		hs.id = "handleSelect";
	}
	target.parentElement.appendChild(hs);
	var option = {
			'name':{
				'param':{'id':"roleName"}
			}
		};
	var param = {
			'data':[{'name':"停用"},{'name':"启用"},{'name':"会员"},{'name':"管理员"}],
			'target':target,
		};
	page.combo("handleSelect",param,option);
}
function save(){
	var items = document.getElementsByClassName("checkBox");
	
	var len = items.length;
	var userIds = new Array();
	var roleNames = new Array();
	for(var i =0;i<len ;i++){
		var ite = items[i];
		if(ite.checked){
			var li = ite.parentElement;
			var userId = li.children[1].userId;
			var role = li.children[li.children.length-2].value;
			//arr.push({userId:userId,roleName:roleName});
			userIds.push(userId);
			roleNames.push(encodeURIComponent(role));
		}
	}
	if(userIds.length==0){
		return;
	}
	var url = "/networkforum/control/user_control_change.do";
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get(url+"?userIds="+userIds+"&roleNames="+roleNames,function(d){
		searchInfo();
	});
	myajax = null;
}
</script>
</head>

<body>
    <div id="rightNav">
        <ul class="rightUl">
            <li>
                <span>姓名</span>
                <input id="un" type="text"/>
            </li>
            <li>
                <span>地区</span>
                <input id="up" type="text"/>
            </li>
            <li>
                <span>注册时间</span>
                 <input name="control_date" id="control_date" type="text" value="" readonly="true" onclick="new Calendar().show(this);" />
            </li>
        </ul>
        <span id="search" onClick="searchInfo();">搜索</span>
    </div>
    <div id="userCenter" class="rightCenter">
        <ul id="rightUlInner" class="rightUlInner">
            <li style="display:none;">
                <input class="checkBox" type="checkbox" style="width:5%;margin-right:4px;"/>
                <span id="userName" style="width:10%;"></span>
                <span id="userSex" style="width:5%;text-align:center;"></span>
                <span id="userAge" style="width:5%;text-align:center;"></span>
                <span id="userPlace" style="width:13%;"></span>
                <span id="registerTime" style="width:16%;"></span>
                <span id="lastLoginTime" style="width:16%;"></span>
                <span id="userRole" style="width:5%;"></span>
                <span id="userState" style="width:5%;"></span>
                <input type="text" onclick="userHandle(event);" readonly style="width:55px;margin-left:10px;"/>
            </li>
            <li id="header">
                <span style="width:5%;">全部</span>
                <span style="width:10%;">姓名</span>
                <span style="width:5%;text-align:center;">性别</span>
                <span style="width:5%;text-align:center;">年龄</span>
                <span style="width:13%;">地区</span>
                <span style="width:16%;">注册时间</span>
                <span style="width:16%;">最近登录时间</span>
                <span style="width:5%;">角色</span>
                <span style="width:5%;">状态</span>
                <span style="width:6%;text-align:right;">管理</span>
            </li>
        </ul>
            <ul id="handle" style="display:none;" class="select">
                <li>
                <span id="roleName"></span>
            </li>
        </ul>
     	<div class="paging" id="paging">
	   		<div class="clear"></div>
	   		<span id="previouPage" style="cursor: pointer;">上一页</span>
	   		<!--  <span id="currentPage2">1</span>-->
	   		<input id="currentPage" type="text" value = "1"/>	
	   		<span id="nextPage" style="cursor: pointer;">下一页</span>
	   		<span id="totalPage">共 1 页</span>
	   	</div>
     	<span id="saveButtom" onclick="save();">保存</span>
     </div>
</body>
<script type="text/javascript" src="control_main.js"></script>
<script src="../js/view.js" type="text/javascript"></script>
<script src="../js/combo.js" type="text/javascript"></script>
<script src="../js/myajax.js" type="text/javascript"></script>
<script src="../js/pageing.js" type="text/javascript"></script>

<script type="text/javascript" src="/networkforum/js/Calendar3.js"></script>
</html>
